
//
// 20120123 - AH - (Huset) Created.
// 20120125 - AH - (Sletten *) equals(Object), hashCode() and toString().
//

package org.soekrat.engine.ontology.ptable;

import org.soekrat.AttributeObject;
import org.soekrat.engine.SoekratName;

/**
 * <p>
 *   Factor in a
 *   {@link ProductTable}.
 * </p>
 * @author Arne Halvorsen (AH)
 * @author Laetitia Le Chatton (LLC) 
 */
public final class ProductTableFactor extends AttributeObject 
{
  private SoekratName m_sname;
  
  /**
   * <p>
   *   Constructor.
   * </p>
   * @param name Factor's name.
   */
  public ProductTableFactor(SoekratName name)
  {
    if (name==null)
    {
      throw new NullPointerException("name");
    }
    
    m_sname=name;
  }
  
  /**
   * <p>
   *   Gets factor's name.
   * </p>
   * @return Name.
   */
  public SoekratName getSoekratName(){ return m_sname; }
  
  /**
   * <p>
   *   Sets name.
   * </p>
   * @param name Name.
   */
  public void setSoekratName(String name)
  {
    name=(name==null) ? "" : name.trim();
    if (name.length()==0)
    {
      throw new IllegalArgumentException("name not given");
    }
    
    m_sname=new SoekratName(name);
  }
  
  @Override
  public boolean equals(Object o)
  {
    if (o instanceof ProductTableFactor)
    {
      ProductTableFactor of=(ProductTableFactor)o;
      return m_sname.equals(of.m_sname);
    }
    
    return false;
  }

  @Override
  public int hashCode(){ return m_sname.hashCode(); }

  @Override
  public String toString(){ return m_sname.toString(); }
  
}
